/*--------------------------------------------------------------------------------------------------
Yatak Operation System Project Copyright 2012-2013
Author : Ilya Churaev
Started : 15 Feb 2013		Updated : 19 Feb 2013
File Name : tty.h			Purpose : Mos terminal
--------------------------------------------------------------------------------------------------*/
#ifndef _YATAK_TTY_H
#define _YATAK_TTY_H

#ifdef __cplusplus
extern "C" {
#endif

#include <sched.h>

#define MAX_NAME 64

struct tty
{
	struct task * window;				// Window for terminal
	struct thread * prev_screen;			// Previos task for print on screen
	struct thread * busy_screen;			// Task which now printing on screen
	struct thread * prev_keyb;			// Previos task for read from keyboard
	struct thread * busy_keyb;			// Task which now reading from keyboard
	char name [MAX_NAME];				// Name of terminal
};

typedef struct tty tty_t;

void set_window (tty_t * tty, struct task * window);
void set_name (tty_t * tty, char * name);
void occupy_screen (struct thread * thread);
void occupy_keyboard (struct thread * thread);
void free_screen (const tty_t * tty);
void free_keyboard (const tty_t * tty);
void create_tty (struct thread * thread, char * name/*, struct task * window*/);
void delete_tty (struct thread * thread);

bool IsAccess2Key (struct thread * thread);
bool IsAccess2Scr (struct thread * thread);

#ifdef __cplusplus
}
#endif

#endif
